Skip to content

fix: windows ssh include glob expansion#2719

Open
janburzinski wants to merge 3 commits into
mainfrom
emdash/fix-ssh-include-glob-on
Open

fix: windows ssh include glob expansion#2719
janburzinski wants to merge 3 commits into
mainfrom
emdash/fix-ssh-include-glob-on

Conversation

@janburzinski

Copy link
Copy Markdown
Collaborator

Summary

  • expand ~\ alongside ~/ when resolving ssh include paths
  • enable windows glob path handling for quoted and unquoted Include patterns

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes SSH Include glob expansion on Windows by treating backslashes as path separators in glob patterns and expanding ~\ as a home-directory prefix. Existing path assertions in tests are also updated from stringContaining('/.ssh/...') to a cross-platform pathSuffix regex helper.

  • expandTilde now handles ~\ on Windows in addition to the existing ~/ check, and resolveIncludePaths passes windowsPathsNoEscape: process.platform === 'win32' to glob() so backslashes in patterns are treated as separators rather than escape characters.
  • Three new tests cover: cross-platform quoted/unquoted Include patterns, Windows backslash path separators (skipped on POSIX), and POSIX ~\ literal behavior (skipped on Windows).

Confidence Score: 5/5

Safe to merge — the change is narrow and additive, only affecting glob option selection and tilde expansion on Windows, with no impact on existing POSIX behaviour.

Both changed files are clean: the production fix is two targeted, platform-gated additions, and the tests correctly exercise all three cases (quoted patterns cross-platform, Windows backslash paths, POSIX ~\ literal). No logic errors or edge-case regressions were identified.

No files require special attention.

Important Files Changed

Filename Overview
apps/emdash-desktop/src/main/core/ssh/config/sshConfigParser.ts Two targeted fixes: expandTilde now handles Windows ~\ prefix, and resolveIncludePaths passes windowsPathsNoEscape to glob on Windows. Logic is correct and minimal.
apps/emdash-desktop/src/main/core/ssh/config/sshConfigParser.test.ts Adds pathSuffix cross-platform regex helper, updates existing assertions, and adds three well-structured platform-conditional tests for the new Windows behaviour.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Include directive line] --> B[tokenize via regex\n quoted or unquoted tokens]
    B --> C{for each token}
    C --> D[stripQuotes]
    D --> E[expandTilde]
    E --> F{starts with ~/ ?\nor Win32: starts with ~\\ ?}
    F -- yes --> G[prepend homedir]
    F -- no --> H[keep as-is]
    G --> I[isAbsolute?]
    H --> I
    I -- yes --> J[use as absolutePattern]
    I -- no --> K[resolve relative to configDir]
    K --> J
    J --> L[glob\n nodir: true\n windowsPathsNoEscape: win32?]
    L --> M[matched file paths]
    M --> N[flat + sort all results]
    N --> O[recursively read each included file]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Include directive line] --> B[tokenize via regex\n quoted or unquoted tokens]
    B --> C{for each token}
    C --> D[stripQuotes]
    D --> E[expandTilde]
    E --> F{starts with ~/ ?\nor Win32: starts with ~\\ ?}
    F -- yes --> G[prepend homedir]
    F -- no --> H[keep as-is]
    G --> I[isAbsolute?]
    H --> I
    I -- yes --> J[use as absolutePattern]
    I -- no --> K[resolve relative to configDir]
    K --> J
    J --> L[glob\n nodir: true\n windowsPathsNoEscape: win32?]
    L --> M[matched file paths]
    M --> N[flat + sort all results]
    N --> O[recursively read each included file]
Loading

Reviews (2): Last reviewed commit: "test(ssh): clarify include glob assertio..." | Re-trigger Greptile

Comment thread apps/emdash-desktop/src/main/core/ssh/config/sshConfigParser.test.ts Outdated
Comment thread apps/emdash-desktop/src/main/core/ssh/config/sshConfigParser.test.ts Outdated
@janburzinski

Copy link
Copy Markdown
Collaborator Author

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant